package cn.newgrand.netcall.smackx.integration;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class AppSysBindPhoneIQ extends IQ{
	
	private String bindPhone;
	private String bindType;
	private String result;
	private String reason;

	@Override
	public String getChildElementXML() {
		StringBuilder buf = new StringBuilder();
        buf.append("<query xmlns=\"ng:iq:appsysbindphone\">");
        if(getBindPhone() != null){
        	buf.append("<bindphone>").append(getBindPhone()).append("</bindphone>");
        }
        if(getBindType() != null){
        	buf.append("<bindtype>").append(getBindType()).append("</bindtype>");
        }
        buf.append("</query>");
        return buf.toString();
	}

	public String getBindPhone() {
		return bindPhone;
	}

	public void setBindPhone(String bindPhone) {
		this.bindPhone = bindPhone;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getBindType() {
		return bindType;
	}

	public void setBindType(String bindType) {
		this.bindType = bindType;
	}
	
	
	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}


	public static class Provider implements IQProvider{

		@Override
		public IQ parseIQ(XmlPullParser parser) throws Exception {
			AppSysBindPhoneIQ bindPhoneIQ = new AppSysBindPhoneIQ();
			boolean done = true;
			while(done){
				int eventType = parser.next();
				if(XmlPullParser.START_TAG == eventType && "result".equals(parser.getName())){
					bindPhoneIQ.setResult(parser.nextText());
				}else if(XmlPullParser.START_TAG == eventType && "reason".equals(parser.getName())){
					bindPhoneIQ.setReason(parser.nextText());
				}else if(XmlPullParser.END_TAG == eventType && "query".equals(parser.getName())){
					done = false;
				}
			}
			return bindPhoneIQ;
		}
		
	} 

	
}
